package com.twu.biblioteca;

public class ContactInformation {
    private final String email;
    private final String address;
    private final String phone;

    public ContactInformation(String email, String address, String phone) {

        if(!email.matches("\\S+@\\S+\\.\\S+"))
            throw new IllegalArgumentException("Email Was Incorrectly Formatted");
        if(address.length() <= 10)
            throw new IllegalArgumentException("Address was too short");
        if(!phone.matches("[0-9]{7,13}"))
            throw new IllegalArgumentException("Phone Number was Incorrectly Formatted");

        this.email = email;
        this.address = address;
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public String getAddress() {
        return address;
    }

    public String getPhone() {
        return phone;
    }

    @Override
    public String toString(){
        return "Email: " + this.email + "\nAddress: " + this.address + "\nPhone: "+ this.phone;
    }
}
